package com.qf.fc.controller;

import com.qf.fc.manager.FileService;
import com.qf.fc.utils.AliOSSUtils;
import com.qf.fc.vo.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@RestController
@RequestMapping("/api/file/")
@Tag(name = "文件接口")
@CrossOrigin
@Slf4j
public class FileController {
    @Resource
    private FileService service;
    @Autowired
    private AliOSSUtils aliOSSUtils;
    @PostMapping("/uploadimg")
    public R uploadImg(@RequestPart MultipartFile file, HttpServletRequest request) throws IOException {
        String upload = aliOSSUtils.upload(file);
        return service.uploadImg(file,upload);
    }
}
